package org.fantasmerica.model.trigger;

import java.util.Map;

import org.fantasmerica.model.DamageType;
import org.fantasmerica.model.character.Combatant;

public class PoisoningStrikeTrigger
		extends OnSuccesfulHitTrigger {

	double damagePerTurn;
	int triggerDuration;
	int poisonDuration;

	private PoisoningStrikeTrigger(double damagePerTurn, int triggerDuration,
			int poisonDuration) {
		if (triggerDuration != MagicNumbers.PERMANENT) {
			setRemoveAfterCombat(true);
		}
		this.damagePerTurn = damagePerTurn;
		this.triggerDuration = triggerDuration;
		this.poisonDuration = poisonDuration;
	}

	@Override
	public void execute(Combatant me, Combatant enemy,
			Map<DamageType, Double> damageCaused, boolean isCriticalHit) {
		enemy.registerTrigger(new PoisonedTrigger(damagePerTurn, poisonDuration));
		if (--triggerDuration == 0) {
			me.removeTrigger(this);
		}
	}

}
